#include <iostream>
#include <stack>

using namespace std;

struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
		val(x), left(NULL), right(NULL) {
	}
};


int TreeDepth(TreeNode* pRoot)
{
	if (pRoot == NULL) return 0;
	int left = TreeDepth(pRoot->left);
	int right = TreeDepth(pRoot->right);
	return 1 + (left > right?left:right);
}

//int main()
//{
//	TreeNode *root = new TreeNode(66);
//	TreeNode *p = root;
//	for (int i = 0; i < 10; ++i)
//	{
//		TreeNode *temp = new TreeNode(i);
//		p->left = temp;
//		p = p->left;
//	}
//	cout << TreeDepth(root);
//	system("pause");
//	return 0;
//}